package com.csaba.swing.gui;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import com.csaba.swing.MainWindow;

@SuppressWarnings( "serial" )
public class StatusBar extends JPanel
{
	private final static Color ONLINE = Color.GREEN;
	private final static Color OFFLINE = Color.BLACK;

	JLabel message;
	JLabel online;

	public StatusBar()
	{
		super(new BorderLayout());
		message = new JLabel("", SwingConstants.LEFT); //$NON-NLS-1$
		message.setBorder(BorderFactory.createEtchedBorder());

		online = new JLabel(MainWindow.getString("StatusBar.offline")); //$NON-NLS-1$
		online.setForeground(OFFLINE);
		online.setBorder(BorderFactory.createEtchedBorder());

		add(message, BorderLayout.CENTER);
		add(online, BorderLayout.EAST);
	}

	public void setMessage( String message )
	{
		this.message.setText("  " + message); //$NON-NLS-1$
	}

	public void clearMessage()
	{
		message.setText(""); //$NON-NLS-1$
	}

	public void setOnline( boolean online )
	{
		if ( online )
		{
			this.online.setText(MainWindow.getString("StatusBar.online")); //$NON-NLS-1$
			this.online.setForeground(ONLINE);
		}
		else
		{
			this.online.setText(MainWindow.getString("StatusBar.offline")); //$NON-NLS-1$
			this.online.setForeground(OFFLINE);
		}
	}

}
